/*
    wavtool-yawu
    Copyright (C) 2015 StarBrilliant <m13253@hotmail.com>

    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 3.0 of the License, or (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this program.  If not,
    see <http://www.gnu.org/licenses/>.
*/

#ifndef YAWU_CMDLINE_PARSER_HPP
#define YAWU_CMDLINE_PARSER_HPP

#include <stdexcept>
#include <vector>
#include <libwintf8/u8str.h>
#include "option_manager.hpp"

namespace YAWU {

/**
 * Parse command line arguments, check errors and store them
 */
class CmdlineParser {
public:
    CmdlineParser(OptionManager &option_manager);
    bool parse_argv(const std::vector<WTF8::u8string> &argv) const;
    static void print_help(const WTF8::u8string &argv0);
    class CmdlineParseError;
protected:
    OptionManager &option_manager;
private:
    static void log_argv(const std::vector<WTF8::u8string> &argv);
    bool analyze_argv(const std::vector<WTF8::u8string> &argv) const;
    static double parse_note_length(const WTF8::u8string &argv4);
};

class CmdlineParser::CmdlineParseError : public std::runtime_error {
public:
    CmdlineParseError() : std::runtime_error("Invalid command line arguments") {}
};

}

#endif
